package movee.resilience4j;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 *
 * @author movee
 */
@Slf4j
@RestController
@RequestMapping(value = "/hello")
public class ExamController {

    private final ExamService examService;

    public ExamController(ExamService examService) {
        this.examService = examService;
    }

    @GetMapping(value = "/haha")
    public String hello() throws IOException {
        log.error("enter hello()");
        String x = "OK";
        try {
            examService.call();
        } catch (Throwable t) {
            x = t.getClass().getName();
            log.error("{}", x);
        }
        return "hello" + x;
    }

}
